<%-- 
    Document   : checkMessage
    Created on : Mar 6, 2014, 11:02:53 AM
    Author     : Jordan
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%>

<c:set scope="request" var="title" value="Message"/>


<sql:setDataSource user="root" password="" driver="com.mysql.jdbc.Driver"
                   url="jdbc:mysql://localhost/bonix"/>


<sql:query var="getMessage">
    Select sender,msg,sent_date from messages 
    where entry_id = ?;
    <sql:param value="${param.entry_id}"/>
</sql:query>


<sql:update sql="UPDATE `bonix`.`messages` SET `status`='read' WHERE `entry_id`=?">
    <sql:param value = "${param.entry_id}"/>
</sql:update>

<!DOCTYPE html>
<html>
    <jsp:include page="head.jsp"/>

    <body>
        <jsp:include page="header.jsp"/>

        <div class="row">
            <div class="container">
                <div class="content row">

                    <div class="containerService">

                        <div class="panel-heading">                            
                            <ul class="navClient navClient-pills">
                                <li class="active"><a href='messages.jsp?receiver=gamby'> Message Inbox </a></li>
                                <li><a href='compose.jsp'> Compose Message </a></li>						
                                <li><a href='sendItems.jsp'> Sent Item </a></li>
                            </ul>
                        </div>

                        <div class="panel-body">
                            <br><hr>
                            <c:forEach var="message" items="${getMessage.rows}">
                                <div class="messages">
                                    <br>
                                    <label>Sender:</label>
                                    <input type="text" name="first" value="${message.sender}" class="form-control" readonly>
                                    <br>
                                    <label>Message:</label>
                                    <textarea class="form-control" name="message" rows="10" cols="50" readonly>${message.msg}</textarea>
                                    <br>
                                </div>
                                <form action="compose.jsp" method="post">
                                    <input type="hidden" name="msgTo" value="${message.sender}"/>
                                    <button type="submit" class="btn btn-primary">REPLY</button>
                                </form>
                            </c:forEach>
                            <form action="delete.jsp?" method="post">
                                <button type="submit" class="btn btn-primary">DELETE</button>
                            </form>

                        </div><!-- END panel-body -->

                    </div><!-- END containerService -->

                </div><!-- END CONTENT CONTENT ROW -->
            </div><!-- END CONTAINER -->
        </div><!-- END ROW -->

        <jsp:include page="footer.jsp"/>

    </body>
</html>
